package collection;

import java.util.HashMap;
import java.util.Map;

public class MapRemoveDemo {

    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<>();
        map.put(1, "1");
        map.put(2, "2");
        map.put(3, "3");
        map.put(4, "4");
        map.put(5, "5");
        map.put(6, "6");
        map.put(7, "7");
        map.put(8, "8");
        map.keySet().removeIf(key -> key < 3);
        System.out.println("after removing keys: " + map);
        map.values().removeIf(value -> Integer.parseInt(value) > 6);
        System.out.println("after removing values: " + map);
    }

}
